using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace CocaCola_Inventory_System.Forms
{
    public partial class AddUser : Form
    {
        public ManageUsers parent;
        Insert i;
        public AddUser()
        {
            InitializeComponent();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            
            int sec = -1;
            if (radioButton1.Checked)
                sec = 3;
            else if (radioButton2.Checked)
                sec = 2;
            else if (radioButton3.Checked)
                sec = 1;

            if (i.addaccount(textBox1.Text, textBox2.Text, sec, ((Container)this.MdiParent).id))
                MessageBox.Show("User Added Successfully");
            else
                MessageBox.Show("Error Occured");
            parent.retrieve();
            this.Dispose();
        }

        private void AddUser_Load(object sender, EventArgs e)
        {
            if (((CocaCola_Inventory_System.Forms.Container)this.MdiParent).security < 2)
            {
                MessageBox.Show("Not Authorized");
                return;
            }
            i = new Insert(((CocaCola_Inventory_System.Forms.Container)this.MdiParent).con);
        }
    }
}